package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhSealInfo;
import com.yinhe.system.service.IYhSealInfoService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 印章基础信息Controller
 * 
 * @author yinhe
 * @date 2022-07-13
 */
@RestController
@RequestMapping("/system/info")
public class YhSealInfoController extends BaseController
{
    @Autowired
    private IYhSealInfoService yhSealInfoService;

    /**
     * 查询印章基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhSealInfo yhSealInfo)
    {
        startPage();
        List<YhSealInfo> list = yhSealInfoService.selectYhSealInfoList(yhSealInfo);
        return getDataTable(list);
    }

    /**
     * 导出印章基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "印章基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhSealInfo yhSealInfo)
    {
        List<YhSealInfo> list = yhSealInfoService.selectYhSealInfoList(yhSealInfo);
        ExcelUtil<YhSealInfo> util = new ExcelUtil<YhSealInfo>(YhSealInfo.class);
        util.exportExcel(response, list, "印章基础信息数据");
    }

    /**
     * 获取印章基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhSealInfoService.selectYhSealInfoById(id));
    }

    /**
     * 新增印章基础信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "印章基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhSealInfo yhSealInfo)
    {
        return toAjax(yhSealInfoService.insertYhSealInfo(yhSealInfo));
    }

    /**
     * 修改印章基础信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "印章基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhSealInfo yhSealInfo)
    {
        return toAjax(yhSealInfoService.updateYhSealInfo(yhSealInfo));
    }

    /**
     * 删除印章基础信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "印章基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhSealInfoService.deleteYhSealInfoByIds(ids));
    }
}
